package com.powernode.controller;


import com.powernode.service.UmsUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.powernode.common.ResultJson;
import com.powernode.entity.UmsRoleUser;
import com.powernode.service.UmsRoleUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户与角色关系表 前端控制器
 * </p>
 *
 * @author lxl
 * @since 2022-04-09
 */
@RestController
@RequestMapping("/umsRoleUser")
public class UmsRoleUserController {
    @Resource
    private UmsRoleUserService umsRoleUserService;

    @Resource
    UmsUserService umsUserService;

    @GetMapping("/getData")
    ResultJson getData(Long roleId){
        Map<String, List> map = new HashMap<String, List>();
        map.put("users",umsUserService.getActive());
        map.put("values",umsRoleUserService.getByRoleId(roleId));
        return ResultJson.success(map);
    }

    @PostMapping("/save")
    ResultJson<Boolean> save(Long roleId, Long[] userIds) {
        return ResultJson.success(umsRoleUserService.save(roleId,userIds),"关联用户成功");
    }


}
